10/01/2002
5:45 PM

 

PreviousNext
 
   
Frankentosh: Building Robots using Mac OS X
 
   
  • Robocode -- API Overview
    • There's also several events which Robot automatically registers with, including onHitByBullet, onBulletHit, onScannedRobotEvent, onRobotDeath
    • Some of these are pretty critical; they attach your "brain" to your "eyes & ears"
    • Let's say you wanted to fire at a robot every time you see one:
    
    public class BeginnerRobot extends Robot {
        public run() {
            while (true) {
                ahead(100); turnLeft(180);
            }
        }
        public onScannedRobotEvent(ScannedRobotEvent e) {
            fire(1);
        }
    }
    
 
   
Ted Stevko, Stevko Studios http://www.plasticnoodle.com